#include <iostream>
#include "basic/basic.h"
#include "thread/thread.h"
#include "thread/thread_pool/thread_pool.h"

void testThreadPool(){
	boost::this_thread::sleep(boost::posix_time::milliseconds(rand() % 100));
	std::cout << "testThreadPool th:" << boost::this_thread::get_id() << std::endl;
}

int main() {
	{	// 测试任务队列
		eyas::thread::init();
		eyas::thread::thread_pool threadPool;
		for(int i=0; i<100; i++){
			threadPool.schedule(&testThreadPool);
			threadPool.schedule([i](){
				boost::this_thread::sleep(boost::posix_time::milliseconds(rand() % 100));
				std::cout << "test thread pool th:" << boost::this_thread::get_id() << std::endl;
				if(i == 99){
					std::cout << "press Enter to the next test" << std::endl;
				}
			});
		}
	}
	std::cout << "Enter exit the test." << std::endl;
	getchar();
	return 0;
}
